﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wicresoft.UnifyShow.Business;
using Oracle.DataAccess.Client;

namespace Wicresoft.UnifyShow.BusinessImpl
{
    public class Performance : Basic, IPerformance
    {
        public List<PerformanceModel> GetPerformanceByDeviceIDAndParameter(int deviceID, string Parameter, DateTime startTime, DateTime endTime)
        {
            QueryParameter[] attParam = new QueryParameter[] {
                        new QueryParameter(){ OracleDbColumnName="DeviceID", OracleDbColumnType=OracleDbType.Decimal,
                        OracleDbColumnValue=deviceID,QueryOperator=QueryOperatorType.equal,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="Parameter", OracleDbColumnType=OracleDbType.NVarchar2, OracleDbColumnSize=30,
                        OracleDbColumnValue=Parameter,QueryOperator=QueryOperatorType.equal,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="TimeStamp", OracleDbColumnType=OracleDbType.Date,
                        OracleDbColumnValue=startTime,QueryOperator=QueryOperatorType.bigger,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="TimeStamp", OracleDbColumnType=OracleDbType.Date,
                        OracleDbColumnValue=endTime,QueryOperator=QueryOperatorType.smaller,PredicateType=PredicateType.where}
                    };
            return ModelHelper<PerformanceModel>.GetModel_By_QueryParams(attParam, null, null, null, oda);
        }

        public List<PerformanceModel> GetPerformanceByDeviceIDAndParameterDisplay(int deviceID, string ParameterDisplay, DateTime startTime, DateTime endTime)
        {
            QueryParameter[] attParam = new QueryParameter[] {
                        new QueryParameter(){ OracleDbColumnName="DeviceID", OracleDbColumnType=OracleDbType.Decimal,
                        OracleDbColumnValue=deviceID,QueryOperator=QueryOperatorType.equal,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="ParameterDisplay", OracleDbColumnType=OracleDbType.NVarchar2, OracleDbColumnSize=30,
                        OracleDbColumnValue=ParameterDisplay,QueryOperator=QueryOperatorType.equal,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="TimeStamp", OracleDbColumnType=OracleDbType.Date,
                        OracleDbColumnValue=startTime,QueryOperator=QueryOperatorType.bigger,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="TimeStamp", OracleDbColumnType=OracleDbType.Date,
                        OracleDbColumnValue=endTime,QueryOperator=QueryOperatorType.smaller,PredicateType=PredicateType.where}
                    };
            return ModelHelper<PerformanceModel>.GetModel_By_QueryParams(attParam, null, null, null, oda);
        }

        public List<PerformanceModel> GetPerformanceParametersByDeviceID(int deviceID, DateTime startTime, DateTime endTime)
        {
            QueryParameter[] attParam = new QueryParameter[] {
                        new QueryParameter(){ OracleDbColumnName="DeviceID", OracleDbColumnType=OracleDbType.Decimal,
                        OracleDbColumnValue=deviceID,QueryOperator=QueryOperatorType.equal,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="TimeStamp", OracleDbColumnType=OracleDbType.Date,
                        OracleDbColumnValue=startTime,QueryOperator=QueryOperatorType.bigger,PredicateType=PredicateType.where},
                        new QueryParameter(){ OracleDbColumnName="TimeStamp", OracleDbColumnType=OracleDbType.Date,
                        OracleDbColumnValue=endTime,QueryOperator=QueryOperatorType.smaller,PredicateType=PredicateType.where}
                    };
            return ModelHelper<PerformanceModel>.GetModel_By_QueryParams(attParam, null, null, null, oda, null,
                new List<string>() { "Parameter", "ParameterDisplay" });
        }
    }
}
